package com.example.web.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import com.example.web.entity.User;
import com.example.web.service.UserService;

@RestController
public class UserController {

	@Autowired
	UserService userService;
	
	@GetMapping("/save")
	public String save() {
		for (int i = 0; i < 10; i++) {
		User u = new User();
			u.setId(Long.valueOf(i));
			u.setName("xxx"+i);
			userService.save(u);
		}
		
		return "success";
	}
	
	@GetMapping("/getUsers")
	public List<User> getUsers() {
		List<User> users = userService.getUsers();
		return users;
	}
	
}
